package businesCard;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import domain.BusinessCard;
import grasil.org.prototyp.R;

/**
 * Created by Peter on 10. 8. 2014.
 */
public class BusinessCardMainActivity extends Activity {

    private static final String LOG = "BusinessCardMainActivity";
    private ListView listView;

    public BusinessCardMainActivity() {
        super();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_business_card_main);
        listView = (ListView) findViewById(R.id.listView);
        listView.setAdapter(new BusinessCardAdapter(this, getBusinessCards()));
        Log.d(LOG, " onCreate(Bundle savedInstanceState)");
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        Log.d(LOG, "onRestoreInstanceState(Bundle savedInstanceState");
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        Log.d(LOG, "onSaveInstanceState(Bundle outState)");
    }

    private List<BusinessCard> getBusinessCards() {
        List<BusinessCard> businessCards = new ArrayList<BusinessCard>();
        BusinessCard b1 = new BusinessCard();
        b1.setName("Business Card 1");
        b1.setPriority(1);
        b1.setDateCreated(new Date());

        BusinessCard b2 = new BusinessCard();
        b2.setName("Business Card 2");
        b2.setPriority(2);
        b2.setDateCreated(new Date());

        BusinessCard b3 = new BusinessCard();
        b3.setName("Business Card 2");
        b3.setPriority(2);
        b3.setDateCreated(new Date());

        businessCards.add(b1);
        businessCards.add(b2);
        businessCards.add(b3);

        return businessCards;
    }
}
